﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _05_多播委托_有参有返回值
{

    public delegate int MyDelegate();

    class Number
    {

        public int Value { get; set; }

        public Number(int value)
        {
            Value = value;
        }

        public int Add1() { return Value + 1; }
        public int Add2() { return Value + 2; }
        public int Add3() { return Value + 3; }

    }

    internal class Program
    {
        static void Main(string[] args)
        {
            Number number = new Number(1);

            MyDelegate myDelegate = new MyDelegate(number.Add1);
            myDelegate += new MyDelegate(number.Add2);
            myDelegate += new MyDelegate(number.Add3);

            //调用所持有的所有方法
            Console.WriteLine("计算结果是:"+myDelegate.Invoke());

            Console.Read();
        }
    }
}
